<?php
//    if (isset($_COOKIE['username'])) {
//        header('location:/lesson05/center.php');
//    }
session_start();
if (isset($_SESSION['username'])) {
    header('location:/lesson05/center.php');
}
?>
<html>
<head>
    <title>用户登录</title>
</head>
<body>
<form action="">
    <input type="text" name="username" >
    <input type="password" name="password">
    <input type="submit" value="登录">
</form>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    jQuery(function() {
        jQuery('form').submit(function () {
            jQuery.post('/lesson05/doLogin.php', jQuery('form').serialize(), function(data){
                if (data.status == 0) {
                    alert(data.message)
                } else {
                    window.location.href = '/lesson05/center.php'
                }
            }, 'json')
            return false;
        })
    })
</script>
</html>